package org.siberia.client;

import org.siberia.client.bean.ActionSuiteDTO;
import org.siberia.client.model.ActionModel;
import org.siberia.client.model.ActionSuiteModel;

import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.binding.FieldBinding;
import com.extjs.gxt.ui.client.binding.FormBinding;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.ScrollContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.FormButtonBinding;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.TimeField;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.VBoxLayout;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.HasText;

public class ActionFormPanel extends FormPanel implements HasText
{
	private FormData formData;  

    private FormBinding binding = new FormBinding(this);  

    private FormButtonBinding buttonBinding = new FormButtonBinding(this);  
	  
	public ActionFormPanel()
	{	
		
	}

	protected void onRender(Element parent, int index)
	{  
	    super.onRender(parent, index);
	    
	    formData = new FormData("-20");
	    
		// name
		TextField<String> fTitle = new TextField<String>();  
		fTitle.setFieldLabel("Title");  
		fTitle.setEmptyText("Title");
		fTitle.setAllowBlank(false);  
	    this.add(fTitle, formData); 

	    // remark
	    TextArea fRemark = new TextArea();  
	    fRemark.setPreventScrollbars(true); 
	    fRemark.setEmptyText("Remark");
	    fRemark.setFieldLabel("Remark");  
	    this.add(fRemark, formData);

	    // all day long
	    CheckBox fAllDayLong = new CheckBox();
	    fAllDayLong.setFieldLabel("All day long");
	    this.add(fAllDayLong, formData);
	    
	    // start date
	    TimeField fStartDate = new TimeField();
	    fStartDate.setFieldLabel("Start date");
	    this.add(fStartDate, formData);
	    
	    // end date
	    TimeField fEndDate = new TimeField();
	    fEndDate.setFieldLabel("End date");
	    this.add(fEndDate, formData);
	    
	    // buttons
	    Button b = new Button("Submit");  
	    this.addButton(b);  
	    this.addButton(new Button("Cancel"));  
	  
	    this.setButtonAlign(HorizontalAlignment.CENTER);
	    this.buttonBinding.addButton(b);  
	    
	    
//	    this.binding.addFieldBinding(new FieldBinding(fName, "name"));  
//	    this.binding.addFieldBinding(new FieldBinding(fDescription, "description"));
	    
	    this.binding.autoBind();

		//this.setSize(700, 400);  
	}
	
	public void bind(ActionModel model)
	{
	    this.binding.bind(model);
	}

	@Override
	public String getText()
	{
		return this.getHeading();
	}

	@Override
	public void setText(String text)
	{	
		this.setHeading(text);
	}
}
